#如果project_name为www，那一个服务器上部署多个网站时会冲突，比如www.doubanxia.com 和 www.shaixuan.org 都是www
project_name = static-doubanxia
version = trunk
#环境有：dev、prod
env = dev
upload_user = u1
release_user = root
server = static.$(env).intra.doubanxia.com
code_dir = /usr/local/nginx/html/$(project_name)/$(version)/
nginx_conf_dir = /usr/local/nginx/conf/sites-enabled/
upload:
	@rm -rf ../tmp/; svn up; svn export ./ ../tmp/;
	@cd ../tmp/; tar -zcvf ../tmp.bz2 ./; exit;
	@ssh $(upload_user)@$(server) 'mkdir -p $(code_dir); mkdir -p $(nginx_conf_dir);'
	@scp ../tmp.bz2 $(upload_user)@$(server):$(code_dir)
	@rm -rf ../tmp/
	@ssh $(upload_user)@$(server) 'cd $(code_dir); tar -zxvf tmp.bz2; cp nginx/conf/sites-enabled/*.$(env).intra.*.conf $(nginx_conf_dir); /usr/local/nginx/sbin/nginx -s reload;'
	@echo upload to $(env) ok
	@exit
release:
	@ssh $(release_user)@$(server) 'cd $(code_dir); mkdir ../enabled/; cp -R ./* ../enabled/; cp nginx/conf/sites-enabled/static.doubanxia.com.conf $(nginx_conf_dir); /usr/local/nginx/sbin/nginx -s reload;'
	@echo release ok
